let token = JSON.parse(localStorage.getItem('token'))

getUserInfo(token, function(data) {
    $('[name="username"]').val(data.username)
    $('[name="nickname"]').val(data.nickname)
    $('[name="email"]').val(data.email)
    let obj = {
        id: data.id,
        nickname: data.nickname,
        email: data.email
    }

    layui.form.on('submit(formDemo)', function(data) {
        $.ajax({
            url: 'http://www.liulongbin.top:3007/my/userinfo',
            method: 'POST',
            beforeSend: function(XMLHttpRequest) {
                XMLHttpRequest.setRequestHeader('Authorization', token)
            },
            data: obj,
            success: function(data) {
                layer.msg(data.message)
            },
            erro: function(data) {
                layer.msg(data.message)
            }
        })
        return false
    })



}, function(data) {
    alert('用户获取失败')
})

//添加表单验证
//lay-verify中对接下面对象名称
layui.form.verify({
    username: [/^[\S]{6,12}$/, '用户昵称不符合规则']
})